<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>lay out页面布局</title>
		<script type="text/javascript" src="../js/jquery-1.8.3.js" ></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js" ></script>
		<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js" ></script>
		<link rel="stylesheet" href="../js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" href="../js/easyui/themes/icon.css" />
		<script src="../js/ztree/jquery.ztree.all-3.5.js"  
                               type="text/javascript" charset="utf-8"></script> 
 	 	<link rel="stylesheet" type="text/css" href="../js/ztree/zTreeStyle.css"/> 
		<script>
			$(function(){
			var setting={
				data:{
					simpleData:{
						enable:true
					}
				},
				callback:{
					onClick:function(event, treeId, treeNode){
						var content="<div style='width: 100%;height: 100%;overflow:hidden;'><iframe style='width: 100%;height: 100%;' scrolling='auto'  src='"+treeNode.page+"'></iframe></div>";
						if(treeNode.page!=undefined&&treeNode.page!=""){
							if($("#mytabs").tabs('exists',treeNode.name)){
								$("#mytabs").tabs('select',treeNode.name);
							}else{
								$("#mytabs").tabs('add',{
									title:treeNode.name,
									content:content,
									closable:true
								});
							}
						}
						
					}
				}
			}
		
			var nodes = [
						{id:1, pId:0, name: "父节点1"},
						{id:11, pId:1, name: "船只",page:"http://www.itcast.cn"},
						{id:12, pId:1, name: "百度",page:"http://www.baidu.com"},
						{id:13, pId:1, name: "传智",page:"http://www.itcast.cn"},
						{id:14, pId:1, name: "度量",page:"http://www.baidu.com"}
			];
			
			$.fn.zTree.init($("#baseMenu"), setting, nodes);
			
			$("#mytabs").tabs({
				onContextMenu:function(e,title,index){
					    e.preventDefault();
						$("#mm").menu('show',{
						left:e.pageX,
						top:e.pageY
					});
				}
			});
			
			$("#closeCorrent").click(function(){
					var tab = $("#mytabs").tabs('getSelected');
					var index = $("#mytabs").tabs('getTabIndex',tab);
					$("#mytabs").tabs('close',index);
			});
			
			$("#closeOthers").click(function(){
				var tabs=$("#mytabs").tabs('tabs');
				var length=tabs.length;
				var tab = $("#mytabs").tabs('getSelected');
				var index = $("#mytabs").tabs('getTabIndex',tab);
				alert(index);
			    for (var i=0;i<index;i++) {
			    	$("#mytabs").tabs('close',0);
			    }
			   for(var i=0;i<length-index-1;i++){
			    	$("#mytabs").tabs('close',1);
			    }
			});
			
			//关闭所有标签
			  $("#closeAll").click(function(){
			    var tabs = $("#mytabs").tabs("tabs");
			    var length = tabs.length;
			    for(var i=0;i<length;i++){
			     $("#mytabs").tabs("close",0);
			    }
			  });
		})
			
		 

		</script>
	</head>
	<body class="easyui-layout">
		<div data-options="region:'north'" style="height: 100px;">北部区域</div>
		<div data-options="region:'west'" style="width: 180px;">西部区域
			<div class="easyui-accordion" data-options="fit:true">
				<div data-options="title:'基础菜单'">
					<ul id="baseMenu" class="ztree"></ul>
					
				</div>
			</div>
		</div>
		<div data-options="region:'center'" >中部区域
			<div id="mytabs" class="easyui-tabs" data-options="fit:true">
				<div data-options="title:'选项卡面板1',closable:true">面板1</div>
				<div data-options="title:'选项卡面板2'">面板2</div>
			</div>
		</div>
		<div data-options="region:'east'" style="width: 80px;">东部区域</div>
		<div data-options="region:'south'" style="height: 100px;">南部区域</div>
		<div  id="mm" class="easyui-menu" style="width:120px;" >
			<div id="closeCorrent">关闭当前</div>
			<div id="closeOthers">关闭其他</div>
			<div class="menu-sep"></div> 
			<div id="closeAll" data-options="iconCls:'icon-cancel'">关闭所有</div> 
		
		</div>
	</body>

